package br.com.massai.model.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "ACTION")
public class Action extends GenericEntity {

	private static final long serialVersionUID = 8623151764236289621L;

	@Id
	@SequenceGenerator(name = "seqAction", sequenceName = "seq_action", allocationSize = 1)
	@GeneratedValue(generator = "seqAction", strategy = GenerationType.SEQUENCE)
	private Long id;

	@Column(name = "ACRONYM", nullable = false, length = 30, columnDefinition = "VARCHAR(30)")
	private String acronym;

	@Column(name = "NAME_ACTION", nullable = false, length = 50, columnDefinition = "VARCHAR(50)")
	private String nameAction;

	@ManyToOne
	@JoinColumn(name = "FUNCTION_ID", nullable = false)
	private Function function;

	public Long getId() {
		return id;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null) return false;
		if(obj instanceof Action)
			if(((Action)obj).getId().equals(this.getId())) return true;

		return false;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNameAction() {
		return nameAction;
	}

	public void setNameAction(String nameAction) {
		this.nameAction = nameAction;
	}

	public Function getFunction() {
		return function;
	}

	public void setFunction(Function function) {
		this.function = function;
	}

	public String getAcronym() {
		return acronym;
	}

	public void setAcronym(String acronym) {
		this.acronym = acronym;
	}
}